package com.scm.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.scm.model.ScmUser;
import com.scm.model.UserModel;


public class OPuserModel
{
	private Connection conn=null;
	private PreparedStatement pp=null;
	private ResultSet rt=null;
	
	private String sql="";
	/**
	 * 得到userModel信息
	 * @param account
	 * @return arraylist
	 */
	public ArrayList<UserModel> getModelCode(String account){
		ArrayList<UserModel> list=new ArrayList<UserModel>();
		sql="select account,modelcode from usermodel where account=" +
				account;
		conn=new DBC().getConn();
		try
		{
			pp=conn.prepareStatement(sql);
			rt=pp.executeQuery();
			if(rt.next()){
				UserModel oeo=new UserModel();
				 oeo.setAccount(rt.getString("account"));
				 oeo.setModelcode(rt.getString("modelcode"));
				 list.add(oeo);
			}
		}
		catch (SQLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		close();
		return list;
	}
	
	/**
	 * 关闭数据库链接
	 */
	private void close() {

		try {
			if (rt != null) {
				rt.close();
				rt = null;
			}
			if (pp != null) {
				pp.close();
				pp = null;
			}
			if (conn != null) {
				conn.close();
				conn = null;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}
}
